<template>
  <div class="Test">
    <button @click="change">点击显示/隐藏msg</button>
    <transition-group appear>
      <h2 v-show="!isShow" key="1">{{ msg }}</h2>
      <h2 v-show="isShow" key="2">两个同样的动画</h2>
    </transition-group>
  </div>
</template>

<script>
export default {
  name: "Test2",
  data() {
    return {
      isShow: "true",
      msg: "你好啊",
    };
  },
  methods: {
    change() {
      this.isShow = !this.isShow;
    },
  },
  components: {},
};
</script>

<style scoped>
.Test {
  margin: 0 auto;
}
h2 {
  margin: 0 auto;
  width: 300px;
  background-color: orange;
}

/* 进入的起点 */
.v-enter,
.v-leave-to {
  transform: translateX(-100%);
}
/* 进入的终点 */
.v-enter-to,
.v-leave {
  transform: translateX(0);
}

.v-enter-active,
.v-leave-active {
  transition: 0.5s linear;
}

/* 离开的起点 */
/* .v-leave {
  transform: translateX(0);
} */
/* 离开的终点 */
/* .v-leave-to {
  transform: translateX(-100%);
} */
</style>
